<?php include "../public/header.php";?>
<?php include "../public/header_public.php";?>
<link rel='stylesheet' href='/static/admin/css/home.css'>
<style>
    .xm-label-block{border: unset!important;}
    .xm-label-block span{font-size: 16px!important;}
    .xm-icon-close{display: none!important;}
    .leftengin .tuo:hover,.danbox:hover{background: #f6f6f6 !important;}
    #role1{float: left}
    #role2{padding-left: 20px;line-height: 30px;float: left}
    #role3{padding-left: 20px;line-height: 30px;float: left}
    .busdiv{width: 200px;float: left;margin-left: 20px}
    .busdiv input{height: 30px!important;}
    #xiang_name{overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
    #xiang_neiname{overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
</style>
<body id="homePage">
<div id="homeBox">
    <div class="minbox" style="margin-bottom: 10px;padding-top: 10px;height: 40px;">
        <div id="role1" class="rolecc">
            <div id="gui_unit" class="xmselect_div" style="width: 300px;height: 40px;margin-left: 20px"></div>
        </div>

        <div id="enginidstr" class="layui-hide"></div>
    </div>
    <div class="leftengin">
        <div class="tongbox tongbox5">
            <div class="tuo">
                <div class="tit">工程承揽总数</div>
                <div class="con" id="tong_all"></div>
            </div>
            <div class="tuo">
                <div class="tit">预承揽工程数</div>
                <div class="con" id="tong_cheng"></div>
            </div>
            <div class="tuo">
                <div class="tit">在建工程数</div>
                <div class="con" id="tong_zai"></div>
            </div>
            <div class="tuo">
                <div class="tit">竣工工程数</div>
                <div class="con" id="tong_jun"></div>
            </div>
            <div class="tuo">
                <div class="tit">完结工程数</div>
                <div class="con" id="tong_wan"></div>
            </div>
        </div>
        <div class="minbox" style="margin-top: 20px;margin-bottom: 10px;padding-top: 10px;height: 40px;">
            <div id="enginid" class="xmselect_div" style="width: 500px;height: 40px;margin-left: 20px"></div>
        </div>

        <div id="daninfo">
            <div class="dan_left hei70 bg1">工程承揽信息</div>
            <div class="dan_right">
                <div class="tou bgrr1">
                    <div>工程名称</div>
                    <div>工程编号</div>
                    <div>业务归属</div>
                    <div>工程管理文件汇编</div>
                    <div>工程负责人</div>
                    <div>联系电话</div>
                </div>
                <div class="nei">
                    <div id="xiang_name" class="colorlan"></div>
                    <div id="xiang_number"></div>
                    <div id="xiang_gui_unit_name"></div>
                    <div id="xiang_neiname" class="colorlan"></div>
                    <div id="xiang_gofuer"></div>
                    <div id="xiang_gofutel"></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei70 bg2">税费收取标准及方式</div>
            <div class="dan_right">
                <div class="tou bgrr2">
                    <div>劳务分包服务费收取标准(%)</div>
                    <div>税款保证金收取标准(%)</div>
                    <div>是否提供进项</div>
                    <div>签订状态</div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="nei_ratefu"></div>
                    <div id="nei_rateshui"></div>
                    <div id="nei_ispiao"></div>
                    <div id="nei_state_name"></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei140 bg3">工程销项发票及回款信息</div>
            <div class="dan_right">
                <div class="tou bgrr3">
                    <div>中标价/合同价(元)</div>
                    <div>工程结算金额(元)</div>
                    <div>已开具销项发票金额(元)</div>
                    <div>累计回款金额(元)</div>
                    <div>回款未开票金额(元)</div>
                    <div>开票未回款金额(元)</div>
                </div>
                <div class="nei">
                    <div id="shimoney" class="colorlan"></div>
                    <div id="shijiemoney" class="colorlan"></div>
                    <div id="piaokaifee" class="colorlan"></div>
                    <div id="gonghuimoney" class="colorlan"></div>
                    <div id="huinokai"></div>
                    <div id="kainohui"></div>
                </div>
                <div class="tou bgrr3">
                    <div>已开具销项发票占比(%)</div>
                    <div>累计回款金额占比(%)</div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="leixiaobi"></div>
                    <div id="leihuibi"></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei140 bg4"><div>工程收取信息<br>（不区分资金渠道）</div></div>
            <div class="dan_right">
                <div class="tou bgrr4">
                    <div>应收取劳务分包服务费(元)</div>
                    <div>已收取劳务分包服务费(元)A</div>
                    <div>应收取税款保证金(元)</div>
                    <div>已收取税款含利息(元)B</div>
                    <div>应收取快递费(元)</div>
                    <div>已收取快递费(元)C</div>
                </div>
                <div class="nei">
                    <div id="yingkoufuwu"></div>
                    <div id="yikoufuwu" class="colorlan"></div>
                    <div id="yingkoushuifei"></div>
                    <div id="yikoushuifei" class="colorlan"></div>
                    <div id="yingkuaifei" class="colorlan"></div>
                    <div id="yikuaifei" class="colorlan"></div>
                </div>
                <div class="tou bgrr4">
                    <div>直接收取(元)D</div>
                    <div>累计已收取(元)A+B+C+D</div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="yiqifei" class="colorlan"></div>
                    <div id="leikoushoufee"></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei70 bg5">工程回款收取及支出</div>
            <div class="dan_right">
                <div class="tou bgrr5">
                    <div>本工程累计工程回款(元)E</div>
                    <div>本工程回款累计支付(元)F</div>
                    <div>本工程回款累计收取(元)G</div>
                    <div>本工程预留金额(元)H</div>
                    <div>本工程回款可用余额(元)E-F-G+H</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="gonghuimoney2" class="colorlan"></div>
                    <div id="gongzhimoneyquben" class="colorlan"></div>
                    <div id="gonghuikoufee" class="colorlan"></div>
                    <div id="jiedongkoufee" class="colorlan"></div>
                    <div id="gonghui_keyu"></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei210 bg6">工程支出信息<br>（不区分资金渠道）</div>
            <div class="dan_right">
                <div class="tou bgrr6">
                    <div>工程收支差额(元)</div>
                    <div>累计工程付款(元)</div>
                    <div>其中工程款付款(元)</div>
                    <div>其中预收款付款(元)</div>
                    <div>其中其他工程付款(元)</div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="gongshouzhicha"></div>
                    <div id="gongzhimoney" class="colorlan"></div>
                    <div id="gongzhimoney_dang" class="colorlan"></div>
                    <div id="gongzhimoney_yufu" class="colorlan"></div>
                    <div id="gongzhimoney_qita" class="colorlan"></div>
                    <div></div>
                </div>

                <div class="tou bgrr6">
                    <div>工程累计支付销售方(元)</div>
                    <div>其中工程款支付销售方(元)</div>
                    <div>其中预收款支付销售方(元)</div>
                    <div>其中其他工程支付销售方(元)</div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="gongzhimoneygogong" class="colorlan"></div>
                    <div id="gongzhimoneygogong_dang" class="colorlan"></div>
                    <div id="gongzhimoneygogong_yufu" class="colorlan"></div>
                    <div id="gongzhimoneygogong_qita" class="colorlan"></div>
                    <div></div>
                    <div></div>
                </div>

                <div class="tou bgrr6">
                    <div>已登记进项发票金额(元)</div>
                    <div>进项发票税额(元)</div>
                    <div>工程采购合同金额(元)</div>
                    <div>工程采购合同结算金额(元)</div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="piaoshoumoney" class="colorlan"></div>
                    <div id="piaoshouratefee" class="colorlan"></div>
                    <div id="contractcaimoney" class="colorlan"></div>
                    <div id="contractcaijiemoney" class="colorlan"></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei70 bg7">工程退税信息</div>
            <div class="dan_right">
                <div class="tou bgrr7">
                    <div>工程累计进项抵扣退税(元)</div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="hougongshuimoney" class="colorlan"></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div class="dan_left hei70 bg8">工程检查及整改</div>
            <div class="dan_right">
                <div class="tou bgrr8">
                    <div>工程检查待整改</div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
                <div class="nei">
                    <div id="cha_dainum"></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                    <div></div>
                </div>
            </div>
            <div class="fenge"></div>

            <div style="clear: both;"></div>
        </div>


    </div>
    <div class="rightengin">
        <div class="tits"><b>工程动态</b></div>
        <div class="chadt">
            <input type="text" id="dongdt" readonly placeholder="请选择" autocomplete="off" class="layui-input bdate_dongdt">
        </div>
        <div class="linecon">
            <ul class="layui-timeline" id="dongList"></ul>
        </div>
    </div>

</div>
<script>
    $('#dongList').on('mouseover','p',function () {
        $(this).addClass('colorlan');
    }).on('mouseout','p',function () {
        $(this).removeClass('colorlan');
    });

    layui.use(['form', 'layer', "laytp",'element','dropdown'], function() {
        var form = layui.form,element = layui.element;
        get_engin_chan_home();

        var laydate = layui.laydate;
        lay('.bdate_sea_range_ymd_cur').each(function(){
            laydate.render({
                elem: this
                ,trigger: 'click'
                ,type: 'date'
                ,range: true
                ,done: function(value, date, endDate){
                    setTimeout(function () {
                        get_engin_chan_home();
                    },200)
                }
            });
        });


        form.on('select(business)', function(data){
            get_engin_chan_home();
        });


        function get_engin_chan_home(gui_unit=0){
            setTimeout(function () {
                var gui_unit = $("input[name='gui_unit']").val() || 0;
                var business = $("#business").val();
                var dts = $("#dts").val();

                facade.ajax({url: ask_engin_chan_home, data:{gui_unit:gui_unit}}).done(function(res){
                    if (res.code === 2000) {
                        var data = res.data;
                        $("#tong_all").html(data.tong_all);
                        $("#tong_cheng").html(data.tong_cheng);
                        $("#tong_zai").html(data.tong_zai);
                        $("#tong_jun").html(data.tong_jun);
                        $("#tong_wan").html(data.tong_wan);


                        xmselect_dan('gui_unit', res.data.gui_unit, res.data.is_gui_unit, function (res) {
                            get_engin_chan_home(res.change[0].id)
                        })

                        $("#enginidstr").text(data.enginidstr);


                        render_from();
                        get_engin_dong_home();
                        get_engin_dan_home();
                    }
                });
            },300);



        }


        $('.bdate_dongdt').datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: "month",
            initialDate: new Date(),
            autoclose: true,
            todayBtn: true,
        }) .on('changeDate',function (e) {
            get_engin_dong_home($("#dongdt").val())
        });

        function get_engin_dong_home(dt=''){
            var enginidstr = $("#enginidstr").text();
            facade.ajax({url: ask_engin_dong_home, data:{enginidstr:enginidstr, dt:dt}}).done(function(res){
                if (res.code === 2000) {
                    var data = res.data;
                    var list = res.data.data;
                    $("#dongdt").val(data.isdt);

                    var str = '';
                    if(list.length > 0){
                        for (var key in list){
                            str += '<li class="layui-timeline-item">';
                            str += '<i class="layui-icon layui-timeline-axis">&#xe643;</i>';
                            str += '<div class="layui-timeline-content layui-text">';
                            str += '<div class="layui-timeline-title" style="font-size: 14px!important;">';
                            str += list[key].created_time;
                            if(list[key].status == 0){
                                str += '<span class="colorlan" style="font-size: 12px!important;">（进行中）</span>';
                            }
                            str += '</div>';
                            str += '<p>'+list[key].summary+'</p>';
                            str += '</div>';
                            str += '</li>';
                        }
                    }else{
                        str += '<div class="nodata"><img src="/static/admin/images/welnodata.png" alt=""><div>暂无数据</div></div>';
                    }



                    $("#dongList").html(str);
                    render_from();
                }
            });
        }
        function get_engin_dan_home(enginid=0){
            $("#daninfo .con").html('');
            xmselect_dan('enginid', [], '');

            var enginidstr = $("#enginidstr").text();
            facade.ajax({url: ask_engin_dan_home, data:{enginidstr:enginidstr, enginid:enginid}}).done(function(res){
                if (res.code === 2000) {
                    var data = res.data.data;

                    if(!res.data.isinfo){
                        return false;
                    }

                    $("#xiang_name").text(data.name).attr('title',data.name).click(function () {
                        openPage('../engin/show.php?id='+data.id);
                    });
                    $("#xiang_number").html(data.number);
                    $("#xiang_gui_unit_name").html(data.gui_unit_name);
                    $("#xiang_gofuer").html(data.gofuer);
                    $("#xiang_gofutel").html(data.gofutel);

                    var neiinfo = res.data.neiinfo
                    if(neiinfo){
                        $("#xiang_neiname").text(neiinfo.name).click(function () {
                            openPage('../contract_nei/show.php?id='+neiinfo.id);
                        });
                        $("#nei_ratefu").text(neiinfo.ratefu);
                        $("#nei_rateshui").text(neiinfo.rateshui);
                        $("#nei_ispiao").text(neiinfo.ispiao);
                        $("#nei_state_name").text(neiinfo.state_name);
                    }


                    var shiinfo = res.data.shiinfo
                    if(shiinfo){
                        $("#shimoney").html(shiinfo.money).click(function () {
                            openPage('../contract_shi/show.php?id='+shiinfo.id);
                        });
                    }else{
                        if(data.winfee){
                            $("#shimoney").html(data.winfee).click(function () {
                                openPage('../engin/show.php?id='+data.id);
                            });
                        }
                    }
                    if(res.data.shijiemoney){
                        $("#shijiemoney").text(res.data.shijiemoney).click(function () {
                            openNavPage('施工合同结算信息','contract_shi_jie/index.php?enginid='+data.id);
                        });
                    }
                    if(res.data.piaokaifee){
                        $("#piaokaifee").text(res.data.piaokaifee).click(function () {
                            openNavPage('销项票明细信息','piao_kai/detail.php?enginid='+data.id);
                        });
                    }
                    if(res.data.gonghuimoney){
                        $("#gonghuimoney").text(res.data.gonghuimoney).click(function () {
                            openNavPage('工程回款信息','hou_gonghui/index.php?enginid='+data.id);
                        });
                    }
                    $("#huinokai").text(res.data.huinokai);
                    if(res.data.kainohui > 0){
                        $("#kainohui").html('<span class="colorhong">'+res.data.kainohui+'</span>');
                    }else{
                        $("#kainohui").text(res.data.kainohui);
                    }
                    $("#leixiaobi").text(res.data.leixiaobi);
                    $("#leihuibi").text(res.data.leihuibi);


                    if(res.data.gongshouzhicha > 0){
                        $("#gongshouzhicha").text(res.data.gongshouzhicha);
                    }else{
                        $("#gongshouzhicha").html('<span class="colorhong">'+res.data.gongshouzhicha+'</span>');
                    }
                    if(res.data.gongzhimoney){
                        $("#gongzhimoney").text(res.data.gongzhimoney).click(function () {
                            openNavPage('工程付款信息','hou_gongzhi/index.php?enginid='+data.id+'&status=1');
                        });
                    }
                    if(res.data.gongzhimoney_dang){
                        $("#gongzhimoney_dang").text(res.data.gongzhimoney_dang).click(function () {
                            // openNavPage('工程付款信息','hou_gongzhi/detail.php?enginid='+data.id+'&status=1&qutype=2');
                            openNavPage('工程支付明细信息','hou_chi_gongzhi/index.php?qutype=2&enginid='+data.id);
                        });
                    }
                    if(res.data.gongzhimoney_yufu){
                        $("#gongzhimoney_yufu").text(res.data.gongzhimoney_yufu).click(function () {
                            // openNavPage('工程付款信息','hou_gongzhi/detail.php?enginid='+data.id+'&status=1&qutype=1');
                            openNavPage('工程支付明细信息','hou_chi_gongzhi/index.php?qutype=1&enginid='+data.id);
                        });
                    }
                    if(res.data.gongzhimoney_qita){
                        $("#gongzhimoney_qita").text(res.data.gongzhimoney_qita).click(function () {
                            // openNavPage('工程付款信息','hou_gongzhi/detail.php?enginid='+data.id+'&status=1&qutype=3');
                            openNavPage('工程支付明细信息','hou_chi_gongzhi/index.php?qutype=3&enginid='+data.id);
                        });
                    }


                    if(res.data.gongzhimoneygogong){
                        $("#gongzhimoneygogong").text(res.data.gongzhimoneygogong).click(function () {
                            openNavPage('工程付款信息','hou_gongzhi/detail.php?dealtype=3&enginid='+data.id);
                        });
                    }
                    if(res.data.gongzhimoneygogong_dang){
                        $("#gongzhimoneygogong_dang").text(res.data.gongzhimoneygogong_dang).click(function () {
                            // openNavPage('工程付款信息','hou_gongzhi/detail.php?dealtype=3&qutype=2&enginid='+data.id);
                            openNavPage('工程支付明细信息','hou_chi_gongzhi/index.php?qutype=2&dealtype=3&enginid='+data.id);
                        });
                    }
                    if(res.data.gongzhimoneygogong_yufu){
                        $("#gongzhimoneygogong_yufu").text(res.data.gongzhimoneygogong_yufu).click(function () {
                            // openNavPage('工程付款信息','hou_gongzhi/detail.php?dealtype=3&qutype=1&enginid='+data.id);
                            openNavPage('工程支付明细信息','hou_chi_gongzhi/index.php?qutype=1&dealtype=3&enginid='+data.id);
                        });
                    }
                    if(res.data.gongzhimoneygogong_qita){
                        $("#gongzhimoneygogong_qita").text(res.data.gongzhimoneygogong_qita).click(function () {
                            // openNavPage('工程付款信息','hou_gongzhi/detail.php?dealtype=3&qutype=3&enginid='+data.id);
                            openNavPage('工程支付明细信息','hou_chi_gongzhi/index.php?qutype=3&dealtype=3&enginid='+data.id);
                        });
                    }


                    if(res.data.piaoshoumoney){
                        $("#piaoshoumoney").text(res.data.piaoshoumoney).click(function () {
                            openNavPage('进项票信息','piao_shou/index.php?enginid='+data.id);
                        });
                    }
                    if(res.data.piaoshouratefee){
                        $("#piaoshouratefee").text(res.data.piaoshouratefee).click(function () {
                            openNavPage('进项票信息','piao_shou/index.php?enginid='+data.id);
                        });
                    }
                    if(res.data.contractcaimoney){
                        $("#contractcaimoney").text(res.data.contractcaimoney).click(function () {
                            openNavPage('采购合同信息','contract_cai/index.php?sttaus=1&enginid='+data.id);
                        });
                    }
                    if(res.data.contractcaijiemoney){
                        $("#contractcaijiemoney").text(res.data.contractcaijiemoney).click(function () {
                            openNavPage('采购合同结算信息','contract_cai_jie/index.php?sttaus=1&enginid='+data.id);
                        });
                    }
                    if(res.data.hougongshuimoney){
                        $("#hougongshuimoney").text(res.data.hougongshuimoney).click(function () {
                            openNavPage('进项抵扣退税信息','hou_gongshui/index.php?enginid='+data.id);
                        });
                    }




                    $("#yingkoufuwu").text(res.data.yingkoufuwu);
                    if(res.data.yikoufuwu){
                        $("#yikoufuwu").text(res.data.yikoufuwu).click(function () {
                            openNavPage('收取劳务分包服务费信息','hou_chi_kou_fuwu/index.php?enginid='+data.id);
                        });
                    }
                    $("#yingkoushuifei").text(res.data.yingkoushuifei);
                    if(res.data.yikoushuifei){
                        $("#yikoushuifei").text(res.data.yikoushuifei).click(function () {
                            openNavPage('收取税款含利息信息','hou_chi_kou_shuifei/index.php?enginid='+data.id);
                        });
                    }
                    if(res.data.yingkuaifei){
                        $("#yingkuaifei").text(res.data.yingkuaifei).click(function () {
                            openNavPage('快递费汇总信息','kuai_hui/index.php?enginid='+data.id);
                        });
                    }
                    if(res.data.yikuaifei){
                        $("#yikuaifei").text(res.data.yikuaifei).click(function () {
                            openNavPage('收取快递费信息','hou_chi_kou_kuaifei/index.php?enginid='+data.id);
                        });
                    }
                    if(res.data.yiqifei){
                        $("#yiqifei").text(res.data.yiqifei).click(function () {
                            openNavPage('直接收取信息','hou_chi_kou_qifei/index.php?enginid='+data.id);
                        });
                    }
                    $("#leikoushoufee").text(res.data.leikoushoufee);



                    if(res.data.gonghuimoney){
                        $("#gonghuimoney2").text(res.data.gonghuimoney).click(function () {
                            openNavPage('工程回款信息','hou_gonghui/index.php?enginid='+data.id);
                        });
                    }
                    if(res.data.gongzhimoneyquben){
                        $("#gongzhimoneyquben").text(res.data.gongzhimoneyquben).click(function () {
                            openNavPage('工程支付明细信息','hou_chi_gongzhi/index.php?qu_enginid='+data.id);
                        });
                    }
                    if(res.data.gonghuikoufee){
                        $("#gonghuikoufee").text(res.data.gonghuikoufee).click(function () {
                            openNavPage('工程回款信息','hou_gonghui/index.php?enginid='+data.id);
                        });
                    }
                    if(res.data.jiedongkoufee){
                        $("#jiedongkoufee").text(res.data.jiedongkoufee).click(function () {
                            openNavPage('直接收取信息','hou_chi_kou_qifei/index.php?isdong=1&enginid='+data.id);
                        });
                    }
                    $("#gonghui_keyu").text(res.data.gonghui_keyu);



                    if(res.data.cha_dainum){
                        $("#cha_dainum").text(res.data.cha_dainum).click(function () {
                            openNavPage('工程检查信息','engin_cha/index.php?status=1&enginid='+data.id+'&isxu='+encodeURI('是')+'&iszheng='+encodeURI('否'));
                        });
                    }


                    xmselect_dan('enginid', res.data.enginlist, res.data.is_enginid, function (res) {
                        get_engin_dan_home(res.change[0].id)
                    })

                    render_from();
                }
            });
        }

    });







</script>
</body>
</html>
